package com.wd.mine.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.wd.common.bean.BuyCarBean
import com.wd.common.bean.FollowBean
import com.wd.mine.R

/**
 * Created by Android Studio.
 * author: 张文龙
 * Date:
 * Time: 2023/9/14 20:00
 * 备注：
 */
class OldCarListAdapter(
    private var context: Context,
    private var list: List<BuyCarBean.QueryBuyOldCarShouCangListBean.Result>
) : RecyclerView.Adapter<OldCarListAdapter.Holder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val inflate = LayoutInflater.from(context).inflate(R.layout.oldcarlist, parent, false)
        return Holder(inflate)
    }

    override fun getItemCount() = list.size

    override fun onBindViewHolder(holder: Holder, position: Int) {
        
        Glide.with(context)
            .load(list.get(position).bgImageUrl)
            .error(R.mipmap.me_data_icon)
            .into(holder.imgid)
        holder.name.setText(list.get(position).carStyleName)
        holder.price.setText(list.get(position).sellingPrice.toString()+"W")

    }

    class Holder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val imgid: ImageView
        val name: TextView
        val price: TextView

        init {
            imgid = itemView.findViewById(R.id.oldcarlist_img)
            name = itemView.findViewById(R.id.oldcarlist_name)
            price = itemView.findViewById(R.id.oldcarlist_price)
        }
    }
}